package com.ruoyi.worker.service.impl;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.worker.constant.Constant;
import com.ruoyi.worker.domain.MonthlyAttendanceIni;
import com.ruoyi.worker.domain.TermAttendanceRules;
import com.ruoyi.worker.domain.workAttendance.AttendanceDailyRecord;
import com.ruoyi.worker.domain.workAttendance.RzScheduleStaffPlan;
import com.ruoyi.worker.mapper.TermAttendanceGroupMapper;
import com.ruoyi.worker.mapper.attendance.AttendanceDailyRecordMapper;
import com.ruoyi.worker.mapper.attendance.RzScheduleStaffPlanMapper;
import com.ruoyi.worker.service.AttendanceSignService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

@Service
@Deprecated
public class AttendanceSignServiceImpl implements AttendanceSignService {

    @Resource
    private AttendanceDailyRecordMapper workAttendanceMapper;
    @Resource
    private TermAttendanceGroupMapper termAttendanceGroupMapper;
    @Resource
    private RzScheduleStaffPlanMapper rzScheduleStaffPlanMapper;



    @Override
    public void addEmploySignTime2AttendanceDailyRecords(List<AttendanceDailyRecord> records) {
        if (records.isEmpty()) {
            throw new ServiceException("记录为空");
        }

        Map<String, Object> requestParam = new HashMap<>();
        String workTime = records.get(0).getWorkTime();
        List<String> idCards = records.stream().map(AttendanceDailyRecord::getIdCard).collect(Collectors.toList());
        requestParam.put(Constant.WORK_TIME, workTime);
        requestParam.put("idCards", idCards);

        // 打卡记录
        List<MonthlyAttendanceIni> passRecords = workAttendanceMapper.listOfAttendancePassRecord(requestParam);
        // 排班表
        List<RzScheduleStaffPlan> rzPlans = rzScheduleStaffPlanMapper.selectRzScheduleStaffPlanListByIds(requestParam);
        // 考勤规则
        TermAttendanceRules rules = termAttendanceGroupMapper.getTermAttendanceRules();
    }

    /**
     * @author: 陈宇寰
     * @date: 2021-12-09 09:16:15
     * @params: 工人考勤子表记录
     * @return: {考勤状态，打卡时间}
     * @description: 通过考勤子表，返回员工的考勤状态和打卡时间
     */
    private void validEmployAttendanceIsNormal(AttendanceDailyRecord attendanceDailyRecord) {
        // 排班时间和考勤规则是不会变的 ，所以这两个查询公共的即可
    }

}
